<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\ResourceCollection;
use Illuminate\Support\Collection;

class PaginatedResourceCollection extends ResourceCollection
{

    /**
     * @param $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'item_list' => $this->collectionList($this->collection),
            'total' => $this->total(),
            'page' => $this->currentPage(),
            'count' => $this->count(),
            'is_next' => $this->hasMorePages(),
            'last_page' => $this->lastPage(),
        ];
    }

    public function collectionList(Collection $collection)
    {
        return $collection;
    }
}
